package com.scott.ch150;

import com.scott.ch150.entity.Baby;
import com.scott.ch150.entity.Child;
import com.scott.ch150.entity.Parent;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2021-12-18 23:12:54
 */
public class Client {

    public static void main(String[] args) {

        List<Parent> parents  = new ArrayList<>();
        parents.add(new Parent());

        List<Child>  children = new ArrayList<>();
        children.add(new Child());

        List<Baby>   babies   = new ArrayList<>();
        babies.add(new Baby());


        print(parents);
        print(children);

        // 放开注释就会报错哦 因为泛型统配符的下限是Child  也就是说可以是Child或Child的父类 但是不能是子类
        // print(babies);

    }


    public static  void print(List<? super Child> list){
        for (Object o : list) {
            System.out.println(o);
        }

    }
}
